/*************************************************************************
	> File Name: 004.shift_and.cpp
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 二  2/23 21:02:50 2021
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>

int shift_and(const char *s, const char *t) {
    int d[256] = {0}, n = 0;
    for (int i = 0; t[i]; i++, n++) {
        d[t[i]] |= (1 << i);
    }
    int p = 0;
    for (int i = 0; s[i]; i++) {
        p = (p << 1 | 1) & d[s[i]];
        if (p & (1 << (n - 1))) return i - n + 1;
    }
    return -1;
}

int main() {
    char s[100], t[100];
    while (~scanf("%s%s", s, t)) {
        printf("shift_and(%s, %s) = %d\n", s, t, shift_and(s, t));
    }
    return 0;
}
